#ifndef     __SENSOR_H
#define     __SENSOR_H

#include <stdint.h>
#include "../utils/nocopyable.h"
#include "../utils/object.h"

namespace main_driver {

class Sensor : public Object<Sensor>, private NoCopyable {

public:
    void init();

    uint16_t adc_value();

    // 大门
    bool is_gate_close() {
        return (read() & 0x01) != 0x00;
    }
    
    // 小门
    bool is_wicket_close() {
        return (read() & 0x02) != 0x00;
    }

    bool is_locked() {
        return (read() & 0x04) != 0x00;
    }

    bool is_film_front() {
        return (read() & 0x10) == 0x00;
    }

    bool is_film_checked() {
        return (read() & 0x20) == 0x00;
    }

    bool is_drop_cup1_checked() {
        return (read() & 0x40) != 0x00;
    }

    bool is_drop_cup2_checked() {
        return (read() & 0x80) != 0x00;
    }

    bool is_straw_checked() {
        return (read() & 0x200) != 0x00;
    }

    bool is_pick1_left() {
        return (read() & 0x400) != 0x00;
    }

    bool is_pick1_right() {
        return (read() & 0x800) != 0x00;
    }

    bool is_pick2_left() {
        return (read() & 0x1000) != 0x00;
    }

    bool is_pick2_right() {
        return (read() & 0x2000) != 0x00;
    }

    bool is_pcik1_raster() {
        return (read() & 0x4000) != 0x00;
    }

    bool is_pick2_raster() {
        return (read() & 0x8000) != 0x00;
    }

    static uint16_t read();
};

extern Sensor sensor;

}


#endif
